<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
    public function login(){
        $this->display();
    }
    //展示登陆
    public function dologin(){
        $post = I('post.');
        $username = $post['username'];
        $pwd = $post['pwd'];
        $res = M('login')->where("username='$username' and pwd='$pwd'")->select();
        //验证Coolie
        if ($res) {
            cookie('username',$username);
            $this->success('登陆成功,正在初始化', U('Index/index'));
        } else {
            $this->error('登陆失败,用户名/密码/错误', U('Login/login'));
        }
    }

    //退出
    public function ex(){
        cookie('username',null);
        $this->display('Login/login');
    }
}
